package com.guchenbo.example.ds.hash;

import java.util.*;

/**
 * Created by CreGu on 2016/6/30.
 */
public class Test2 {

    void testMap(Map<String, String> map) {
        map.put("k1", "v1");
        map.put("k3", "v3");
        map.put("k4", "v4");
        map.put("k2", "v2");
        map.put("k2", "v22");

        for (Map.Entry<String, String> entry : map.entrySet()) {
            System.out.println(entry.getKey() + ": " + entry.getValue());
        }
    }

    void testSet(Set<String> set) {
        set.add("k1");
        set.add("k3");
        set.add("k4");
        set.add("k2");

        for (String key : set) {
            System.out.println(key);
        }
    }

    void testList(List<String> list) {
        list.add("k1");
        list.add("k3");
        list.add("k4");
        list.add("k2");

        for (String key : list) {
            System.out.println(key);
        }
    }

    public static void main(String[] args) {
        Test2 test2 = new Test2();
        test2.testMap(new HashMap<String, String>());
        test2.testMap(new LinkedHashMap<String, String>());
        test2.testMap(new TreeMap<String, String>());

        test2.testSet(new HashSet<String>());
        test2.testSet(new LinkedHashSet<String>());
        test2.testSet(new TreeSet<String>());

        test2.testList(new ArrayList<String>());
    }
}
